package com.hy.controller;

import com.hy.bean.PurchaseApplyDetail;
import com.hy.bean.RespBean;
import com.hy.service.PurchaseApplyDetailService;
import com.hy.service.impl.PurchaseApplyDetailServiceImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * (PurchaseApplyDetail)表控制层
 *
 * @author makejava
 * @since 2024-04-29 14:47:14
 */
@RestController
@RequestMapping("purchaseApplyDetail")
public class PurchaseApplyDetailController {
    /**
     * 服务对象
     */

    private PurchaseApplyDetailService purchaseApplyDetailService = new PurchaseApplyDetailServiceImpl();

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<PurchaseApplyDetail> queryById(@PathVariable("id") int id) {
        return ResponseEntity.ok(this.purchaseApplyDetailService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param purchaseApplyDetail 实体
     * @return 新增结果
     */
    @PostMapping("add")
    public RespBean add(@RequestBody PurchaseApplyDetail purchaseApplyDetail) {
        return purchaseApplyDetailService.insert(purchaseApplyDetail);
    }

    /**
     * 编辑数据
     *
     * @param purchaseApplyDetail 实体
     * @return 编辑结果
     */
    @PutMapping("update")
    public RespBean edit(@RequestBody PurchaseApplyDetail purchaseApplyDetail) {
        return purchaseApplyDetailService.update(purchaseApplyDetail);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("delete/{id}")
    public RespBean deleteById(@PathVariable Integer id) {
        return purchaseApplyDetailService.deleteById(id);
    }

}

